package cn.tedu.shoot;

import java.awt.image.BufferedImage;

public class Boss extends FlyingObject implements EnemyScore {
    static final int WIDTH = 300;
    static final int HEIGHT = 150;

    private int index = 0;
    private int index2 = 0;
    private int change = 0;
    public int change2 = 0;
    private int xSpeed = 2;
    private int ySpeed = 2;
    private int life = 350;
    private int fire = 0;

    Boss() {
        super(WIDTH, HEIGHT, World.WIDTH / 2 - WIDTH / 2, -HEIGHT);
        System.out.println("bossx坐标：" + x);
        System.out.println("bossy坐标：" + y);
        System.out.println("boss宽：" + WIDTH);
        System.out.println("boss高：" + HEIGHT);
       /* life = 3;
        fire = 100;*/
    }

    //boss子弹生成
    public BossBullet[] shoot() {
        int xStep = this.width / 4;
        BossBullet[] bossbs = new BossBullet[2];
        bossbs[0] = new BossBullet(this.x + 1 * xStep + 10, this.y + HEIGHT, 0);
        bossbs[1] = new BossBullet(this.x + 3 * xStep - 10, this.y + HEIGHT, 0);
        return bossbs;
    }

    //boss移动1
    public void step() {
        y += ySpeed;
    }

    //boss移动2
    public void step2() {
        x += xSpeed;
        if (x >= World.WIDTH - WIDTH || x <= 0) {
            xSpeed = -xSpeed;
        }
    }

    public void step3() {

    }

    //获取图片
    public BufferedImage getImage() {
        if (isLive()) {
            if (index++ % 15 == 0) {
                change++;
            }
            return Images.boss[change % Images.boss.length];
        } else if (isDead()) {
            if (index2++ % 10 == 0) {
                change2++;
            }
            BufferedImage img = Images.bossbom[change2];

            if (change2 == Images.bossbom.length-1) {
                stated = REMOVE;
            }

            return img;
        } else {
            return null;
        }
    }

    //boss生命值减少
    public void subtractLife() {
        life -= 5;
    }

    public int getLife() {
        return life;
    }

    @Override
    public int getScore() {
        return 10;
    }
}
